<script>
  function add(...args) {
    let all = [...args]
    function fn(...newargs) {
      all = [...all, ...newargs]
      return fn
    }

    fn.valueOf = function () {
      if (!all.length) return
      return all.reduce((sum, cur) => sum + cur, 0)
    }
    return fn
  }
</script>
